<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>海报管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script type="text/javascript">
        $(function () {
            initForm();
            saveEvent();
        });

        //初始化表单
        function initForm() {
            $("#formSet1").ligerForm({
                validate: true
            });
        }

        //保存事件
        function saveEvent() {
            $("#saveBtn1").click(function (event) {
                var form = liger.get("formSet1");
                if (!form.valid()) {
                    top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                    return false; //验证不通过，不执行以下代码
                }
                var data = form.getData();

                /*var regPhone = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
                var regMobile = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
                if (!regPhone.test(data.channelMp) && !regMobile.test(data.channelMp)) {
                    top.$.ligerDialog.SQalert({content: "请输入正确的手机号或者座机号1！", SQ_type: "error"});
                    return
                }*/
                // $.ligerDialog.success("data.kpMp ==>【" + data.kpMp + "】");
                // if (data.kpMp != "") {
                //     // $.ligerDialog.success(regPhone.test(data.kpMp)+"1");
                //     // $.ligerDialog.success(regMobile.test(data.kpMp)+"2");
                //     if (!regPhone.test(data.kpMp) && !regMobile.test(data.kpMp)) {
                //         top.$.ligerDialog.SQalert({content: "请输入正确的手机号或者座机号2！", SQ_type: "error"});
                //         return
                //     }
                // }


                var url = '<%=path%>/carloan/odrphonenoteweb/add.do';
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: url,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            var callback = GET_W2Wcallback();
                            callback();
                            Remove_navTab();
                        } else {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        }
    </script>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <form id="formSet1">
        <table class="layout2col1">
            <tbody>
            <tr>
                <td valign="top">
                    <div class="fieldset1 tabel_col clearFix">
                        <%-- <div class="fieldBox col_100_auto">
                            <div class="label">注册系统</div>
                            <div class="field">
                                <select name="sysCd" id="sysCd" validate="{required:true,select:true}">
                                    <option value=" " >请选择</option>
                                    <c:forEach items="${syscdlist }" var="syscdop">
                                        <option value="${syscdop.key }" <c:if test="${cmsbnrdc.sysCd == syscdop.key}">selected</c:if>>${syscdop.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div> --%>
                        <div class="fieldBox col_100_auto">
                            <div class="label">电销渠道&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="compNm" id="compNm " type="text" class="ui-textbox"
                                       value="${comp.compNm}">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden">
                            <div class="label">compId&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="compId" id="compId " type="text" class="ui-textbox"
                                       value="${comp.id}">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden">
                            <div class="label">cstId&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="cstId" id="cstId " type="text" class="ui-textbox"
                                       value="${comp.odrChannelInfoDTO.id}">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">联系人姓名&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="channelNm" id="channelNm" type="text" class="ui-textbox"
                                       value="${comp.odrChannelInfoDTO.channelNm}">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">联系人电话<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="channelMp" id="channelMp" type="text" class="ui-textbox"
                                       value="${comp.odrChannelInfoDTO.channelMp}"><%--validate="{required:true}"--%>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">联系人职位&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="position" id="position">
                                    <c:forEach items="${position}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>

                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">接通状况<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="isConnected" id="isConnected">
                                    <option value=" " selected>--请选择--</option>
                                    <option value="0">未接通</option>
                                    <option value="1">已接通</option>
                                </select>
                            </div>
                        </div>

                        <div class="fieldBox col_100_auto" hidden="hidden" id="isRealDiv">
                            <div class="label">是否真实有效&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="isReal" id="isReal">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden" id="notConnectedReasonDiv">
                            <div class="label">未接通原因&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="notConnectedReason" id="notConnectedReason">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">空号停机</option>
                                    <option value="1">无人接听</option>
                                    <option value="2">通话中/忙音</option>
                                    <option value="3">挂断</option>
                                </select>
                            </div>
                        </div>

                        <div class="fieldBox col_100_auto" hidden="hidden" id="isKpDiv">
                            <div class="label">是否kp&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="isKp" id="isKp">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" id="intentionDiv" hidden="hidden">
                            <div class="label">客户意向&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="intention" id="intention">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">没有意向</option>
                                    <option value="1">可深入沟通</option>
                                    <option value="2">高意向有车可做</option>
                                    <option value="3">已和狮桥合作</option>
                                    <option value="4">公司不做车相关业务</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden" id="isOthermanDiv">
                            <div class="label">是否有其他联系人&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="isOtherman" id="isOtherman">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>


                        <div class="fieldBox col_100_auto" hidden="hidden" id="kpNmDiv">
                            <div class="label">新联系人姓名&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="kpNm" id="kpNm" type="text" class="ui-textbox"
                                       value="">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden" id="kpMpDiv">
                            <div class="label">新联系人电话<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="kpMp" id="kpMp" type="text" class="ui-textbox"
                                       value=""><%--validate="{required:true}"--%>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto" hidden="hidden" id="kpPositionDiv">
                            <div class="label">新联系人职位&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="kpPosition" id="kpPosition">
                                    <c:forEach items="${position}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">三日内是否需要跟进&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <select name="isThreedayFollowIn" id="isGj">
                                    <option value=" ">--请选择--</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>

                        <div class="fieldBox col_100_auto">
                            <div class="label">备注</div>
                            <div class="field">
                                         <textarea name="bz" id="bz" rows="6" class="ui-textarea l-textarea"
                                                   style="width:80%"
                                                   value="" validate="{maxlength:200}"></textarea>
                            </div>
                        </div>
                        <div id="btnsBox" class="btnsBox">
                            <%--                                <input name="pictId" id="pictId" type="text" style="display: none;" value="${wechatPicRec.id}"/>--%>
                            <span id="saveBtn1" class="sq-button sq-button-round">保存</span>
                            <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
                        </div>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<div class="clearLine"></div>
</body>
<script type="text/javascript">

    $(function () {
        var form = new liger.get("formSet1");
        if (${comp.odrPhoneNoteWebDTO!=null}) {
            $("#isConnected").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.isConneced}');

        }
        isConnectedChange(form);
        $("#position").ligerComboBox().setValue('${comp.odrChannelInfoDTO.position}');
        $("#notConnectedReason").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.notConnecedReason}');
        $("#isThreedayFollowIn").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.isThreedayFollowin}');
        $("#isKp").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.isKp}');
        $("#isReal").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.isReal}');
        isOthermanChange(form);
        $("#intention").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.intention}');
        <%--$("#kpPosition").ligerComboBox().setValue('${comp.odrPhoneNoteWebDTO.kpPosition}');--%>
    })


    $("#isConnected").change(function () {
        $("#formSet1").ligerForm();
        var form = new liger.get("formSet1");
        isConnectedChange(form);
    })

    $("#isOthermanDiv").change(function () {
        $("#formSet1").ligerForm();
        var form = new liger.get("formSet1");
        isOthermanChange(form);
    })


    function isConnectedChange(form) {
        var val = $("#isConnected").val();
        if (val == '0') {
            $("#notConnectedReasonDiv").show();//未接通原因展示
            $("#isRealDiv").hide();
            $("#isKpDiv").hide();
            $("#isOthermanDiv").hide();
            $("#intentionDiv").hide();
            $("#kpNmDiv").hide();
            $("#kpMpDiv").hide();
            $("#kpPositionDiv").hide();
            form.setData({
                isKp: " ",
                isReal: " ",
                isOtherman: " ",
                kpNm: " ",
                kpMp: " ",
                kpPosition: " ",
                intention: " ",
            });
        } else if (val == '1') {
            $("#notConnectedReasonDiv").hide();//未接通原因隐藏
            $("#isRealDiv").show();
            $("#isKpDiv").show();
            $("#isOthermanDiv").show();
            $("#intentionDiv").show();
            form.setData({
                notConnectedReason: " ",
                kpNm: " ",
                kpMp: " ",
                kpPosition: " ",
            });
        }
    }


    function isOthermanChange(form) {
        var val = $("#isOtherman").val();
        if (val == '0') {
            $("#kpNmDiv").hide();
            $("#kpMpDiv").hide();
            $("#kpPositionDiv").hide();
            form.setData({
                kpNm: " ",
                kpMp: " ",
                kpPosition: " ",
            });
        } else if (val == '1') {
            $("#kpNmDiv").show();
            $("#kpMpDiv").show();
            $("#kpPositionDiv").show();
        }

    }

</script>
</html>